﻿@model PagedList.IPagedList<shradhabookstores.Admin>
@using PagedList;
@using PagedList.Mvc;
@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
@using (Html.BeginForm("Index", "AccountAdmin", FormMethod.Get))
{
    <p>
        Find by name: @Html.TextBox("SearchString", ViewBag.CurrentFilter as string)
        <input type="submit" value="Search" />
    </p>
}

<table class="table">
    <tr>
        <th>
            @Html.ActionLink("UserName", "Index", new { sortOrder = ViewBag.NameSortParm, currentFilter = ViewBag.CurrentFilter })

        </th>
        
        <th>
            @Html.ActionLink("Level", "Index", new { sortOrder = ViewBag.LevelSortParm, currentFilter = ViewBag.CurrentFilter })
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.UserName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Level_)
            </td>
            <td>
              
                @Html.ActionLink("Details", "Details", new { id = item.ID }) |
              @if (Convert.ToInt32(Session["Level"].ToString()) == 1)
                {
                @Html.ActionLink("Edit", "Edit", new { id = item.ID });
              }
              |
                @if (Convert.ToInt32(Session["Level"].ToString()) == 1)
                {                     
                 @Html.ActionLink("Delete", "Delete", new { id = item.ID });
                }
               
            </td>
        </tr>
    }

</table>
<br />
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount

@Html.PagedListPager(Model, page => Url.Action("Index",
    new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }))
